package copyfile02;

import java.io.*;

/*
利用BufferedInputStream和BufferedOutputStream做文件拷贝
 */
public class BufferedCopy01 {
    public static void main(String[] args) throws IOException {
        //1.利用FileInnerputStream关联文件，再利用BufferedInputStream包装FileInputStream，提高读取效率
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Day23/风景.jpg"));

        //2利用FileOutputStream关联文件，在利用BufferedOutputStream包装FileOutputStream，提高效率
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Day23/风景_copy_3.jpg"));

        //3.循环读写
        int b;
        while ((b = bis.read()) != -1) {
            bos.write(b);
        }

        //4.关流释放资源
        bis.close();
        bos.close();
    }
}
